import React, { Component } from 'react';
import { connect, history } from 'umi';
/**
 * 初始化加载内容
 */
const loginPath = '/user/login';
class InitialInfoComp extends Component {
  constructor(props) {
    super(props);
  }
  componentDidMount() {
    const pathname = history.location.pathname;
    if (pathname === loginPath) {
      return;
    }
    this.fetchCurrentUser();
    this.fetchSystemDic();
    // this.fetchLoadBaiDuMap();
  }
  //获取当前用户
  fetchCurrentUser() {
    const { dispatch } = this.props;
    dispatch &&
      dispatch({
        type: 'user/fetchCurrent',
      });
  }
  //获取系统字段字典
  fetchSystemDic() {
    const { dispatch } = this.props;
    dispatch &&
      dispatch({
        type: 'global/fetchDict',
      });
  }
  //引入加载百度地图
  fetchLoadBaiDuMap() {
    const { dispatch } = this.props;
    dispatch &&
      dispatch({
        type: 'global/fetchBaiDuMap',
      });
  }

  render() {
    return null;
  }
}

export default connect(
  () => ({}),
  (dispatch) => {
    return { dispatch };
  },
  null,
  { forwardRef: true },
)(InitialInfoComp);
